package com.desksoft.service;

import java.util.List;
import java.util.Map;

import com.desksoft.common.BaseService;
import com.desksoft.dao.CategoryDao;
import com.desksoft.entity.Category;

/**
 * 文章service
 * @author forever
 *
 */
public class CategoryService  extends BaseService<Category> {

	private CategoryDao  categoryDao;

	/**
	 * 通过语言ID查找
	 * @param languageId
	 * @return
	 */
	public List<Category> findByLanguageId(String languageId) {
		return categoryDao.findByLanguageId(languageId);
	}

	
	public CategoryDao getCategoryDao() {
		return categoryDao;
	}

	public void setCategoryDao(CategoryDao categoryDao) {
		this.categoryDao = categoryDao;
	}

	/**
	 * 插入数据
	 * @param category
	 * @return
	 */
	public Integer insertSelective(Category category) {
		return categoryDao.insertSelective(category);
	}


	@Override
	public Integer delete(String id) {
		return this.categoryDao.deleteByPrimaryKey(id);
	}


	@Override
	public Integer updateSequ(List<Map<String, Object>> listSequ) {
		Integer f = 0 ;
		for(Map<String, Object> map : listSequ){
			Integer temp = categoryDao.updateSequ(map);
			if(temp == 1){
				f++;
			}
		}
		if(listSequ.size() == f){
			return 1 ;
		}
		return 0 ;
	}
}
